package com.sunday.leaf.old.leaf.snowflake.constants;

import com.sunday.common.leaf.config.LeafProperties;
import lombok.extern.slf4j.Slf4j;

/**
 * @Description: zk 常量
 * @Author: zsy
 * @Create: 2022/10/24 11:04
 */
@Slf4j
public class SnowflakeConstants {

    /**
     * zk 路径前缀
     * 例 : /snowflake/sunday-leaf-starter
     */
    public static String PREFIX_ZK_PATH;

    /**
     * zk 持久化全路径
     * 例 : /snowflake/sunday-leaf-starter/forever
     */
    public static String PATH_FOREVER;

    /**
     * 雪花算法本地节点ID存储地址
     * 例 : C:\Users\ThinkPad\AppData\Local\Temp\/sunday-leaf-starter/leafconf/15000/workerID.properties
     */
    public static String LOCAL_PATH;

    public static void init(LeafProperties leafProperties) {
        PREFIX_ZK_PATH = "/snowflake/" + leafProperties.getName();
        PATH_FOREVER = PREFIX_ZK_PATH + "/forever";
        LOCAL_PATH = leafProperties.getPath() + "/" + leafProperties.getName() + "/leafconf/" + leafProperties.getPort() + "/workerID.properties";
    }

}
